// 柯里化案例
// 提取或匹配数组中的相应内容 
// ''.match(/\s+/g)
// ''.match(/\d+/g)

const _ = require('lodash')


const curried = _.curry((reg,str)=>{
    return str.match(reg)
}) 
const hasSpace = curried(/\s+/g)
const hasNumber = curried(/\d+/g)

// console.log('has space', hasSpace('Hello'))
// console.log('has number', hasNumber('125xss'))

// filter柯里化
const filter = _.curry((callback, array)=>array.filter(callback))
const findSpace = filter(hasSpace)
console.log(filter(hasSpace, ['AA AA', 'BB_BB']))
console.log(findSpace(['AA_AA', 'BB BB']))